package com.dylan.shot.head.interceptor;

import com.dylan.shot.head.shiro.ShiroHelper;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by Dylan on 2017/9/22.
 */
public class MemberInfoInterceptor extends HandlerInterceptorAdapter {

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        if (modelAndView != null) {
            // 加入内部工作者
            modelAndView.addObject("member", ShiroHelper.getCachedMember());
            // 加入当前请求的URI,用于菜单展示
            modelAndView.addObject("requestUri", request.getRequestURI());
        }
    }
}
